package com.demo;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.utils.viewport.StretchViewport;
import com.demo.actors.Progress;

public class DemoScreen extends ScreenAdapter {

	Stage		demoStage;
	Progress	progress;
	float		time	= 0;

	public DemoScreen() {
		demoStage = new Stage(new StretchViewport(480, 800));
		progress = new Progress();

		progress.setPosition((demoStage.getWidth() - progress.getWidth()) / 2,
				(demoStage.getHeight() - progress.getHeight()) / 2);
		progress.addAction(Actions.forever(Actions.sequence(
				Actions.scaleTo(1F, 1.0F, 1.0F, Interpolation.swing),
				Actions.scaleTo(0.8F, 0.8F, 1.0F, Interpolation.swing))));
		demoStage.addActor(progress);

	}

	@Override
	public void render(float delta) {
		super.render(delta);

		if (time <= 1) {
			time += delta / 20;
		}
		time = time > 1F ? 0 : time;
		progress.setPrecent(time);
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		Gdx.gl.glClearColor(1, 1, 1, 1);
		demoStage.act(delta);
		demoStage.draw();
	}

}
